Discover log4j rollingfileappender example xml, include the articles, news, trends, analysis and practical advice about log4j rollingfileappender example xml on alibabacloud.com
Configuration information of Log4j. xml and Log4j. xml
Source code
1
Log4j. xml configuration
Value = "[% d {dd HH: mm: ss, SSS/} %-5 p] [% t] % c {2/}-% m % n"/>Value = "[% d {MMdd HH: mm: ss SSS/} %-5 p] [% t] % c {3/}-% m %
log4j, You need to include the following JAR packages in your classpath, it depends on which slf4j and the log4j version you are using. For example:
The slf4j-api-1.6.1.jar-jar for slf4j API
The log4j-1.2.16.jar-jar for log4j API
Slf4j-log4j12-1.6.1.jar-
Example of how MyBatis3 outputs SQL using log4j on the console, mybatis3log4j
Why do I need to output SQL statements on the console?
Of course, it is convenient for development and debugging.
If a database-related operation encounters a problem, we can quickly troubleshoot the problem based on the output SQL statement.
Output Information:
[Org. mybatis. spring. SqlSessionUtils]-Creating a new SqlSession[O
preceding outputs and shields all the subsequent outputs. Here, we recommend two types: Error: only error information is recorded; debug: detailed information of all errors is recorded. In the production configuration, disable the "apply to console" option and only enable file). The following two consoles and files represent the location of log output, and the following two can be named at will, to be clear and easy to understand, you can use words with a glance. For
Log4j is really simple, simple to the point of outrageous. Not to log it. So I'll give you a log, and then you can write something with log, and first come to a complete class example:
Package test;
import Org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Public class Test {
Static Log log = Logfactory.getlog (Test.class);
Public void log () {
Log.debug ("Debug Info.");
Log.inf
I have not written examples in the log4j usage notes. In this article, I will write a complete application instance of log4j.
In the log4j usage notes, we already know that the same log information can be output to multiple output destinations at the same time. In the following example, I will demonstrate how to output
Configuration parameter Description:
(1). The output mode Appender generally has 5 kinds:
Org.apache.log4j.RollingFileAppender (scrolling file, automatic recording of the latest log)
Org.apache.log4j.ConsoleAppender (console)
Org.apache.log4j.FileAppender (file)
org.apache.log4j.DailyRollingFileAppender (generate one log file per day)
Org.apache.log4j.WriterAppender (send log information to any specified place in streaming form
The log frameworks available for MyBatis include SLF4J, Apache Commons Logging, Log4J, and JDK logging. This article will transform the previous example to demonstrate the simple use of Log4J source code: http://down.51cto.com/data/521820. This source code corresponds to the fifth case of the following content ).
First, copy the related
already contains the functions of Webapprootlistener.General configuration Type the following example: XML code
log4jrefreshinterval in Web. XML
Log4jrefreshinterval is 3000 to open a watchdog thread to scan for changes in configuration files every 3 seconds.
The ability to dynamically modify the Log4j.properties key, the container scans the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.